Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​ArraySegment<​T>

Assembly: System.Runtime

Implemented Interfaces

Delimits a section of a one-dimensional array.

Properties

public T[]
Array
Gets the original array containing the range of elements that the array segment delimits.
public int
Count
Gets the number of elements in the range delimited by the array segment.
public static ArraySegment<​T>
Empty
Represents the empty array segment. This field is read-only.
public T
Item
public int
Offset
Gets the position of the first element in the range delimited by the array segment, relative to the start of the original array.

Methods

public void
CopyTo​(ArraySegment<​T> destination)
Copies the contents of this instance into the specified destination array segment of the same type <typeparamref name="T" /> .
destination The array segment into which the contents of this instance will be copied.
public void
CopyTo​(T[] destination)
Copies the contents of this instance into the specified destination array of the same type <typeparamref name="T" /> .
destination The array of type <typeparamref name="T" /> into which the contents of this instance will be copied.
public void
CopyTo​(T[] destination, int destinationIndex)
Copies the contents of this instance into the specified destination array of the same type <typeparamref name="T" /> , starting at the specified destination index.
destination The array of type <typeparamref name="T" /> into which the contents of this instance will be copied.
destinationIndex The index in <paramref name="destination" /> at which storing begins.
public bool
Equals​(ArraySegment<​T> obj)
Determines whether the specified <see cref="T:System.ArraySegment`1" /> structure is equal to the current instance.
Returns <see langword="true" /> if the specified <see cref="T:System.ArraySegment`1" /> structure is equal to the current instance; otherwise, <see langword="false" /> .
obj The structure to compare with the current instance.
public bool
Equals​(object obj)
Determines whether the specified object is equal to the current instance.
Returns <see langword="true" /> if the specified object is a <see cref="T:System.ArraySegment`1" /> structure and is equal to the current instance; otherwise, <see langword="false" /> .
obj The object to be compared with the current instance.
public Enumerator<​T>
GetEnumerator​()
Returns an enumerator that can be used to iterate through the array segment.
Returns An enumerator that can be used to iterate through the array segment.
public int
GetHashCode​()
Returns the hash code for the current instance.
Returns A 32-bit signed integer hash code.
public ArraySegment<​T>
Slice​(int index)
Forms a slice out of the current array segment starting at the specified index.
Returns An array segment that consists of all elements of the current array segment from <paramref name="index" /> to the end of the array segment.
index The index at which to begin the slice.
public ArraySegment<​T>
Slice​(int index, int count)
Forms a slice of the specified length out of the current array segment starting at the specified index.
Returns An array segment of <paramref name="count" /> elements starting at <paramref name="index" /> .
index The index at which to begin the slice.
count The desired length of the slice.
public T[]
ToArray​()
Copies the contents of this array segment into a new array.
Returns An array containing the data in the current array segment.
public string
ToString​()
Inherited from ValueType
Returns the fully qualified type name of this instance.
Returns The fully qualified type name.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .